<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>核酸结果分析对比</title>
<style>body{ background-color:#fbfbfb;}</style>
<script type="text/jscript" src="js/jquery-3.6.0.min.js"></script>
 <script>
$(function(){
		    $(".info p").each(function(){
					var txt = $(this).parent().siblings().attr("src");
					$(this).html(txt);
			})
			
		   $(".menu span").click(function(){
				var index = $(this).index();
			   $(this).addClass("current").siblings().removeClass("current");
		       $(".content .mous_li").eq(index).show().siblings().hide();
		    })
})
</script>

<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="hs_box">
	<div class="pic_left">
		<img src="images/pic_03.jpg" />
	</div>
	<div class="form_right">
		<div class="menu"><center><span class="current">核酸检测结果上传</span><span>检测点上传</span></center></div>
			<div class="content">
				  <div class="mous_li">
				  	<div class="b01"><!--未上传数据库模块-->
						<center id="base" style="display: none">
								<button id="baseDataButton" class="file_css" onclick="baseupload.click()">上传全市基础库数据</button>
								<input type="file" onchange="changeBaseData()" name="file" id="baseupload" style="display: none;" />
								<p>当前还未上传全市基本库数据，请先上传！</p>
								<button type="submit" class="file_css file_css02" onclick="uploadBase()">上传</button>
						</center>
						<center  id = "check" >
							<button class="file_css" id="checkUploadButton" onclick="checkupload.click()">上传全市核酸检测数据</button>
							<input type="file" onchange="changeCheckResult()" name="file" id="checkupload" style="display: none;" />
							<button type="submit" class="file_css file_css02"  onclick="uploadCheck()">开始分析</button>
						</center>
					</div>
					<div class="b01" id="analying"  style="display:none;"><!--分析中-->
						<center>
						<p class="wancheng"><img src="images/s4.gif" /><br /><br />数据正在上传和分析中，请耐心等待...</p>
						</center>
					</div>
					<div class="b01" style="display: none" id="wancheng"><!--分析结果-->
						<center>
						<p class="wancheng"><img src="images/dou_06.jpg" /><br /><br />数据分析完成，请下载结果...</p>
						<button class="file_css file_css02" onclick="downloadZip()">下载对比结果文件</button>
							<a style="display:none;" target="_blank" id="download"></a>
						<button class="file_css" onclick="reUpload()">重新上传文件</button>
						</center>
					</div>
				  </div>
				  
				  <div class="mous_li" style="display:none;">
				  	<div class="b01">
						<center>
						<button class="file_css" id="checkPointButton" onclick="checkpoint.click()">上传核酸点</button>
							<input type="file" name="file" onchange="changeCheckPoint()" id="checkpoint" style="display: none;" />
						<button class="file_css file_css02" onclick="uploadCheckPoint()">开始分析</button>
						</center>
					</div>
				  </div>
			</div>
	</div>
	<div class="clear"></div>
</div>

</body>
<script>
	var zipPath = "";
	function init(){
		$.ajax({
			url: "/query/base_data",
			success: function(result){
				console.log(result)
				if(result===0){
					$("#check").hide()
					$("#base").show()
				}else {
					$("#base").hide();
					$("#check").show();
				}

			}});
	}
	$(function(){
		init()
	})

	function downloadZip(){
		console.log("zipPath",zipPath)
		$("#download").attr("href","/download?path="+zipPath)
		document.getElementById("download").click();
	}
	function reUpload(){
		$("#wancheng").hide();
		$("#analying").hide();
		$("#check").show();
	}
	function uploadBase(){
		var baseupload = document.getElementById("baseupload");
		console.log(baseupload.files[0])
		var formData = new FormData();
		formData.append("file", baseupload.files[0]);
		$.ajax({
			url: "/add/base_data",
			method: 'post',
			data: formData,
			cache: false, // 上传文件无需缓存
			processData : false, // 使数据不做处理
			contentType : false, // 不要设置Content-Type请求头
			success: function(result){
				console.log(result)
				init()
				alert("上传成功")
			}
		});	}
	function uploadCheck(){

		var checkupload = document.getElementById("checkupload");
		console.log(checkupload.files[0])
		var formData = new FormData();
		formData.append("file", checkupload.files[0]);
		$("#analying").show();
		$.ajax({
			url: "/add/check_result",
			method: 'post',
			data: formData,
			cache: false, // 上传文件无需缓存
			processData : false, // 使数据不做处理
			contentType : false, // 不要设置Content-Type请求头
			success: function(result){
				console.log(result)
				zipPath = result;
				$("#wancheng").show();
				$("#analying").hide();
				$("#check").hide();
			}
		});

	}
	function uploadCheckPoint(){
		var checkpoint = document.getElementById("checkpoint");
		console.log(checkpoint.files[0])
		var formData = new FormData();
		formData.append("file", checkpoint.files[0]);
		$.ajax({
			url: "/add/check_point",
			method: 'post',
			data: formData,
			cache: false, // 上传文件无需缓存
			processData : false, // 使数据不做处理
			contentType : false, // 不要设置Content-Type请求头
			success: function(result){
				alert("上传成功")
			}
		});

	}

	function changeCheckPoint(){
		var checkpoint = document.getElementById("checkpoint");
		var file = checkpoint.files[0];
		if(file!==undefined){
			$("#checkPointButton").text(file.name)
		}
	}
	function changeBaseData(){
		var checkpoint = document.getElementById("baseupload");
		var file = checkpoint.files[0];
		if(file!==undefined){
			$("#baseDataButton").text(file.name)
		}
	}
	function changeCheckResult(){
		var checkpoint = document.getElementById("checkupload");
		var file = checkpoint.files[0];
		if(file!==undefined){
			$("#checkUploadButton").text(file.name)
		}
	}
</script>
</html>
